<?php

namespace api\web\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'mobile'   => 'require|length:11|regex:^1[3-9]\d{9}$',
        'code'     => 'require|length:4',
        'password' => 'min:6|max:32',
        'name' => 'require',
        'image' => 'require',
        'user_id' => 'require|integer',
        'money' => 'require|float',
    ];

    protected $message = [
        'mobile.require'   => '手机号不能为空',
        'name.require'   => '姓名不能为空',
        'image.require'   => '图片不能为空',
        'mobile.length'    => '手机号必须为11位',
        'mobile.regex'     => '手机号格式不正确',
        'mobile.unique'    => '手机号已被使用',
        'password.min'     => '密码长度不能小于6位',
        'password.max'     => '密码长度不能超过32位',
        'code.require'     => '验证码不能为空',
        'code.length'      => '验证码必须为4位',
        'user_id.require'  => '用户ID不能为空',
        'user_id.integer'  => '用户ID必须是整数',
        'money.require'    => '充值金额不能为空',
        'money.float'      => '充值金额必须是浮点数',
    ];

    protected $scene = [
        'register' => ['mobile', 'code'],
        'login'    => ['mobile', 'code'],
        'sendsms'  => ['mobile'],
        'updateProfile' => ['mobile', 'image', 'name'],
        'addMoney' => ['money'],
    ];
}